#include <iostream>
#include <string>
using namespace std;

void _init()
{
    int a[10]; // local arr is not default initialized so all elements are odd value.
    for (auto &i : a)
        cout << i << " ";
    cout << endl;
}
void _length()
{
    int a[10];
    int len_arr = sizeof(a) / sizeof(int);

    char str[10] = "hello";
    // or
    // string str = "hello";
    int len_str = strlen(str);

    cout << "len_arr: " << len_arr << endl;
    cout << "len_str: " << len_str << endl;
}

void _iter_2d()
{
    int a[3][4] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

    // easy
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }

    for (int(&row)[4] : a)
    {
        for (auto &j : row)
            cout << j << " ";
        cout << endl;
    }

    // hard with point
    for (int(*row)[4] = a; row != a + 3; row++)
    {
        for (int *col = *row; col != *row + 4; col++)
            cout << *col << " ";
        cout << endl;
    }
}

int main()
{
    _iter_2d();
    _init();
    _length();
    return 0;
}